import request from '@/utils/request';
import { requestWrapper, randomInt } from '@/utils/mock';

// 获取服务器监控信息
export function getServerInfo() {
  return requestWrapper(
    // 真实API请求
    () => request({
      url: '/monitor/server',
      method: 'get'
    }),
    // 模拟数据
    {
      cpu: {
        cpuNum: 8,
        total: 100,
        sys: randomInt(3, 8),
        used: randomInt(20, 50),
        free: 0 // 会在前端计算: 100 - used - sys
      },
      mem: {
        total: 16384,
        used: randomInt(4000, 10000),
        free: 0, // 会在前端计算: total - used
        usage: 0 // 会在前端计算: (used / total) * 100
      },
      jvm: {
        total: 2048,
        used: randomInt(500, 1500),
        free: 0, // 会在前端计算: total - used
        usage: 0, // 会在前端计算: (used / total) * 100
        name: "Java HotSpot(TM) 64-Bit Server VM",
        version: "1.8.0_265",
        startTime: "2023-05-01 10:00:00"
      },
      system: {
        computerName: "SERVER-NAME",
        computerIp: "192.168.1.100",
        osName: "Linux",
        osArch: "amd64",
        userDir: "/home/user/app"
      },
      disks: [
        {
          dirName: "/",
          sysTypeName: "ext4",
          typeName: "本地磁盘",
          total: 500,
          free: 300,
          used: 200,
          usage: 40.0
        },
        {
          dirName: "/data",
          sysTypeName: "ext4",
          typeName: "数据磁盘",
          total: 1000,
          free: 400,
          used: 600,
          usage: 60.0
        }
      ]
    }
  );
} 